﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/callcenter/list_view.master" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        string n = Request.QueryString["h"] ?? "500";
        int h = int.Parse(n) - 100;

    }

    protected void page_Init(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["InvWhere"] = "1=0";

        }
    }



    #region search
    protected void Search_Click(object sender, EventArgs e)
    {
        string where = "";
        if (txt_no.Text.Trim() != "")
        {
            where = "ActivityID='" + SafeValue.SafeInt(txt_no.Text.Trim(), 0) + "'";
        }
        else if (this.txt_from.Value != null && this.txt_to.Value != null)
        {
            string dateFrom = this.txt_from.Date.ToString("yyyy-MM-dd");
            string dateTo = this.txt_to.Date.AddDays(1).ToString("yyyy-MM-dd");
            where = string.Format("JobDate>='{0}' and JobDate<'{1}'", dateFrom, dateTo);
        }

        Session["CfsImp"] = where;
        this.dsCall.FilterExpression = where;
    }
    private string GetWhere(string where, string s)
    {
        if (where.Length > 0)
            where += " and " + s;
        else
            where = s;
        return where;
    }
    #endregion

    protected void grid_Order_CustomUnboundColumnData(object sender, ASPxGridViewColumnDataEventArgs e)
    {
    }
    protected void grid_Order_RowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
    {
    }
    protected void grid_Order_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
    {
        if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return;
        ASPxLabel label = grid_Order.FindRowCellTemplateControl(e.VisibleIndex, null, "lab_InvoiceNo") as ASPxLabel;
        if (label == null || label.Text.Length < 3)
        {
        }
        else
        {
            e.Row.BackColor = System.Drawing.Color.LightGreen;
        }
    }

    protected void grid2_Init(object sender, EventArgs e)
    {
        ASPxGridView grd = sender as ASPxGridView;
        if (grd != null)
        {
            grd.ForceDataRowType(typeof(Touchmax.OpOrder));
        }
    }

    protected void grid2_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
    {
    }

    protected void grid2_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
    }

    protected void grid2_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
    }

    
    </script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style>
    div {font-size:10px;font-family:Verdana;}
    </style>
    <script type="text/javascript">
        var order = 0;
        function ViewCall(n) {
            order = n;
            runApp("/Pages/Callcenter/EditPage/CallView.aspx?no=" + n);
        }

        function ShowCall(n) {
            if(n==0)
                parent.Popup('/Pages/callcenter/EditPage/CallEdit.aspx?no=0', 'Service Call Log', 1050, 540);
             else
                 parent.Popup('/Pages/callcenter/EditPage/CallEdit.aspx?no=' + order, 'Service Call Log', 1050, 540);
         }

    </script>
</asp:Content>

<asp:Content ID="title1" ContentPlaceHolderID="Title1" Runat="Server">
<table width=100% cellpadding="4">
    <tr>
    <td align=left class="bb">
        Quick Navigation
    </td>
    <td align=right class="bb">
    </td>
    </tr>
</table>
</asp:Content>
<asp:Content ID="title2" ContentPlaceHolderID="Title2" Runat="Server">

<table width="100%">
           <tr>
                
                <td>
                    Date
                </td>
                <td>
                    <dxe:ASPxDateEdit ID="txt_from" Width="90" runat="server" EditFormat="Custom" EditFormatString="dd/MM/yyyy">
                    </dxe:ASPxDateEdit>
                </td>
                <td>
                    To
                </td>
                <td>
                    <dxe:ASPxDateEdit ID="txt_to" Width="90" runat="server" EditFormat="Custom" EditFormatString="dd/MM/yyyy">
                    </dxe:ASPxDateEdit>
                </td>
                <td>
                    <dxe:ASPxButton ID="ASPxButton1" Width="90" runat="server" Text="Search" >
                    </dxe:ASPxButton>
                </td>
                <td align=right width="100%">
                </td>
            </tr>
        </table>

</asp:Content>
<asp:Content ID="title3" ContentPlaceHolderID="Title3" Runat="Server">
<table width="100%">
           <tr>
                
                <td width="*" align="left">
                <dxe:ASPxButton ID="ASPxButton9" Width="110" runat="server" Text="New Call" AutoPostBack="False">
                            <ClientSideEvents Click="function(s, e) {
                    ShowCall(0);
                        }" />
                        </dxe:ASPxButton>

                </td>
                <td align=right width="100">
                <dxe:ASPxButton ID="ASPxButton22" Width="110" runat="server" Text="Open Call Log" AutoPostBack="False">
                            <ClientSideEvents Click="function(s, e) {
                    ShowCall(1);
                        }" />
                        </dxe:ASPxButton>
                </td>
            </tr>
        </table>

</asp:Content>

<asp:Content ID="Page1" ContentPlaceHolderID="Page1" Runat="Server">

     
        <table>
         <tr>
        <td colspan=2 align=left>
        <asp:RadioButton GroupName="time" Checked="true" ID="RadioButton0" runat="server" Text = "This Month" /><br /> 
        <asp:RadioButton GroupName="time" ID="RadioButton1" runat="server" Text = "Last Month" /><br /> 
        <asp:RadioButton GroupName="time" ID="RadioButton3" runat="server" Text = "Year to Date" /> <br />
        <asp:RadioButton GroupName="time" ID="RadioButton2" runat="server" Text = "" />
<asp:DropDownList id="ddl" 
           runat="server">
         <asp:ListItem>2010-01</asp:ListItem>
         <asp:ListItem>2010-02</asp:ListItem>
         <asp:ListItem>2010-03</asp:ListItem>
         <asp:ListItem>2010-04</asp:ListItem>
         <asp:ListItem>2010-05</asp:ListItem>
         <asp:ListItem>2010-06</asp:ListItem>
         <asp:ListItem>2010-07</asp:ListItem>
         <asp:ListItem>2010-08</asp:ListItem>
         <asp:ListItem>2010-09</asp:ListItem>
      </asp:DropDownList>

<br />
        </td>
        </tr>
        <tr>
        <td colspan=2>
        <hr />
        </td>
        </tr>
        <tr>
        <td colspan=2 align=left>
       <asp:RadioButton  GroupName="status" Checked="True" ID="RadioButton6" runat="server" Text = "All" /><br /> 
        <asp:RadioButton GroupName="status" ID="RadioButton4" runat="server" Text = "Open" /><br /> 
        <asp:RadioButton GroupName="status" ID="RadioButton5" runat="server" Text = "Closed" /><br />
        </td>
        </tr>
        <tr>
        <td colspan=2>
        <hr />
        </td>
        </tr>
        <tr>
        <td width=60>
                    Call Log No
                </td>
                <td>
                    <dxe:ASPxTextBox ID="txt_no" Width="70" runat="server" Text="">
                    </dxe:ASPxTextBox>
                </td>
                </tr>
        </table>

</asp:Content>
<asp:Content ID="Page2" ContentPlaceHolderID="Page2" Runat="Server">


<asp:SqlDataSource ID="dsPickColorFormular"	SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1001 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickColorMatch" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1002 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickMarketingSource" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1003 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickOrderStatus" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1004 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickColorOption" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1005 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickDepartment" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1006 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickWorkType" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1007 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickWorkLocation" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1008 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickServiceType" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1009 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickRepairStatus" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1010 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickCustomerGroup" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1011 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickPrimaryColor" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1012 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickBranchGroup" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1013 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickEmployeeGroup" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1014 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickPhoneType" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1015 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickBranchStatus" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1016 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickEmploymentStatus" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1017 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickPaymentTerm" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1018 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickVehicleYear" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1019 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickPaymentMethod" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1020 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickCallProcess" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1021 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickCallStatus" SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1022 order by ddItemSort" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />


<asp:SqlDataSource ID="dsPickCountry" SelectCommand="select * from ddCountry order by countryname" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickState" SelectCommand="select * from ddState where countrycode='CA' order by statename" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickCity" SelectCommand="select * from ddCity where statecode='BC' order by statename" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />
<asp:SqlDataSource ID="dsPickZoneCode" SelectCommand="select distinct zonecode from ddPostal order by zonename" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"  />



        <asp:SqlDataSource ID="dsPickTech" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"
         SelectCommand="select EmployeeID, Firstname  from [BoEmployee] where EmployeeGroupID=119 order by firstname"  />
        <asp:SqlDataSource ID="dsEmployee" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"
         SelectCommand="select EmployeeID, Firstname  from [BoEmployee] order by firstname"  />
        <wilson:DataSource ID="dsCall" runat="server" ObjectSpace="Touchmax.Manager.ORManager"
            TypeName="Touchmax.OpActivity" KeyMember="ActivityID" FilterExpression="1=1" />

        <dxwgv:ASPxGridView ID="grid_Order" ClientInstanceName="grid_Order" runat="server"
            DataSourceID="dsCall" Width="100%" KeyFieldName="ActivityID" AutoGenerateColumns="False"
             oncustomunboundcolumndata="grid_Order_CustomUnboundColumnData"  OnHtmlRowCreated="grid_Order_RowCreated" OnHtmlRowPrepared="grid_Order_HtmlRowPrepared" >
            <SettingsPager Mode="ShowAllRecords">
            </SettingsPager>
            <SettingsCustomizationWindow Enabled="True" />
            <Settings ShowGroupPanel="false" />
            <Settings ShowVerticalScrollBar="false" />
            <SettingsBehavior AllowFocusedRow="true" />
            <Columns>
                
                <dxwgv:GridViewDataTextColumn Caption="Call Status" FieldName="ActivityID" VisibleIndex="1" Width="60" SortIndex="0" SortOrder="Descending">
                    <DataItemTemplate>
                        <a onclick='ViewCall("<%# Eval("ActivityID") %>");'><%# Eval("ActivityID") %>:<%# Eval("CallStatus") %></a>
                    </DataItemTemplate>
            
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Status" Width="60" FieldName="CallStatus" VisibleIndex="2">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="New Client" Width="60" FieldName="NewClientStatus" VisibleIndex="3">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Customer" Width="90" FieldName="FirstName" VisibleIndex="4">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Postal"  FieldName="PostalCode" VisibleIndex="4">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Technician" Width="100" FieldName="Technician" VisibleIndex="3">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Source" Width="100" FieldName="CallSource" VisibleIndex="8">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataDateColumn Caption="Appointment" FieldName="AppointmentDate" PropertiesDateEdit-DisplayFormatString="dd/MM/yyyy"   VisibleIndex="3">
                   
                </dxwgv:GridViewDataDateColumn>
                <dxwgv:GridViewDataDateColumn Caption="Time" FieldName="AppointmentDate" PropertiesDateEdit-DisplayFormatString="MMM dd, yyyy"   VisibleIndex="9">
                    <DataItemTemplate>
                    <%# Eval("Time1") %> - <%# Eval("Time2") %>
                    </DataItemTemplate>
                </dxwgv:GridViewDataDateColumn>
               
                    
            </Columns>
        </dxwgv:ASPxGridView>

        

</asp:Content>
<asp:Content ID="Page3" ContentPlaceHolderID="Page3" Runat="Server">
</asp:Content>

